import java.net.*;
import java.io.*;

//runs the download server on the peer client
public class pThread extends Thread{
	
	//Boolean listening = true;
	ServerSocket sSocket = null;
	saperePeer main=null;
	
	public pThread(saperePeer s)
	{
		super("pThread");
		this.main=s;
		try {
	         sSocket = new ServerSocket(4443);
	     } catch (IOException e) {
	         System.err.println("Could not listen on port: 4443.");
	         System.exit(1);
	     }
	}

	public void run() {

		try {
			while (main.listening) {
				new dThread(sSocket.accept(), main).start();
			}
			sSocket.close();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

}
